;*******************************************************************************
; spurious_ISR_64.asm
;
; contains kernel ISRs for handling spurious interrupts from the PIC and APICs
;
; Author: Aidan Goddard - 20/6/13
;
; All the functions do is increase a counter for each spurous IRQ so that system
; software may keep track of any spurious IRQs and take action if any of them
; are deemed to be occuring far too often.
;
; System specs state that EOIs do not need to be sent for spurious IRQs.
;
; No locks are required for global data as counts do not need to be exact.
;
;*******************************************************************************

global ISR_PIC_SP_7
global ISR_PIC_SP_15
global ISR_APIC_SP

; PIC vector 7
ISR_PIC_SP_7:
	; save trashed registers
	push	rdi
	push	rax
	
	; increase counter value
	mov	rdi, 0x100e00000 + 4	; get base address of system info table + offset to counter value
	mov	eax, [rdi]		; get counter value at said address
	inc	eax			; increase it
	mov	[rdi], eax		; put it back
	
	; restore trashed registers
	pop	rax
	pop	rdi

	; finished, return
	iretq

; PIC vector 15
ISR_PIC_SP_15:
	; save trashed registers
	push	rdi
	push	rax
	
	; increase counter value
	mov	rdi, 0x100e00000 + 8	; get base address of system info table + offset to counter value
	mov	eax, [rdi]		; get counter value at said address
	inc	eax			; increase it
	mov	[rdi], eax		; put it back
	
	; restore trashed registers
	pop	rax
	pop	rdi

	; finished, return
	iretq

; APIC spurious vector
ISR_APIC_SP:
	; save trashed registers
	push	rdi
	push	rax
	
	; increase counter value
	mov	rdi, 0x100e00000 + 12	; get base address of system info table + offset to counter value
	mov	eax, [rdi]		; get counter value at said address
	inc	eax			; increase it
	mov	[rdi], eax		; put it back
	
	; restore trashed registers
	pop	rax
	pop	rdi

	; finished, return
	iretq

